package com.star.jersey.oss.kodo.autoconfig;

import com.star.jersey.oss.kodo.config.KodoOssConfig;
import com.star.jersey.oss.kodo.service.KodoOssService;
import com.star.jersey.oss.kodo.service.impl.KodoOssServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: TODO
 * @motto: 代码源于生活，高于生活艺术
 * @author: zhouhengzhe
 * @date: 2022/10/21 17:03
 * @since 1.0
 **/
@Configuration
@ConditionalOnProperty(prefix = "kodo.oss", name = {"accessKey", "secretKey", "bucket"})
@EnableConfigurationProperties(KodoOssConfig.class)
public class KodoOssAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public KodoOssConfig kodoOssConfig() {
        return new KodoOssConfig();
    }

    @Bean
    @ConditionalOnMissingBean
    public KodoOssService kodoOssService(KodoOssConfig kodoOssConfig) {
        return new KodoOssServiceImpl(kodoOssConfig);
    }


}
